package com.qs.controller;


import com.qs.model.dto.CommentDto;
import com.qs.model.dto.StoreDto;
import com.qs.model.dto.StoreGoodsDto;
import com.qs.response.Response;
import com.qs.service.IStoreService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 店铺表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-03-25
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/store")
public class StoreController {

    private final IStoreService storeService;


    /**
     * 根据店铺id获取店铺详细信息
     * @param storeId
     * @return
     */
    @GetMapping("/query/{storeId}")
    public Response queryStoreDetail(@PathVariable("storeId") Integer storeId) {
        StoreDto storeDto = storeService.queryStoreDetail(storeId);
        return Response.success(storeDto);
    }

    /**
     * 查询某个店铺下的所有商品
     * @param storeId
     * @return
     */
    @GetMapping("/query/goods/{storeId}")
    public Response queryGoodsList(@PathVariable("storeId") Integer storeId) {
        List<StoreGoodsDto> list = storeService.queryGoodsList(storeId);
        return Response.success(list);
    }

    /**
     * 查询某个店铺下的所有评论
     * @param storeId
     * @return
     */
    @GetMapping("/query/comment/{storeId}")
    public Response queryCommentList(@PathVariable("storeId") Integer storeId) {
        List<CommentDto> list = storeService.queryCommentList(storeId);
        return Response.success(list);
    }
}
